<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class ListGrid extends Canvas implements IRenderable {
	
	protected $alternateRecordStyles;
	protected $alternateBodyStyleName;
	protected $alternateRecordFrequency;
	
	protected $alwaysShowEditors;
	
	protected $animateRemoveRecord;
	protected $animateRemoveSpeed;
	protected $animateRemoveTime;
	
	protected $animateRollOver;
	protected $animateRollUnder;
	protected $animateSelectionUnder;
	
	protected $arrowKeyAction;
	
	protected $autoFetchData = true;
	protected $autoFetchDisplayMap;
	protected $autoFetchTextMatchStyle;
	
	protected $canAutoFitFields;
	protected $autoFitAllText;
	protected $autoFitFieldText;
	protected $autoFitClipFields;
	protected $autoFitExpandField;
	protected $autoFitFieldsFillViewport;
	protected $autoFitFieldWidths;
	protected $autoFitIconFields;
	protected $autoFitMaxColumns;
	protected $autoFitMaxWidth;
	protected $autoFitWidthApproach;
	protected $autoFitData;
	protected $autoFitExtraRecords;
	protected $autoFitMaxHeight;
	protected $autoFitMaxRecords;
	protected $headerAutoFitEvent;
	
	protected $autoSaveEdits;
	protected $canEdit;
	protected $canRemoveRecords;
	protected $editByCell;
	protected $editEvent;
	protected $editOnFocus;
	protected $enterKeyEditAction;
	protected $escapeKeyEditAction;
	protected $listEndEditAction;
	protected $rowEndEditAction;
		
	protected $backgroundComponent;
	protected $baseStyle;
	protected $bodyBackgroundColor;
	protected $bodyOverflow;
	protected $bodyStyleName;
	
	protected $booleanFalseImage;
	protected $booleanImageHeight;
	protected $booleanImageWidth;
	protected $booleanPartialImage;
	protected $booleanTrueImage;
	
	protected $canAcceptDroppedRecords;
	protected $canDragRecordsOut;
	protected $canDragSelect;
	protected $canDragSelectText;
	protected $dragDataAction;
	protected $dragTrackerMode;
	protected $dragTrackerStyle;
	
	protected $canAddFormulaFields;
	protected $canAddSummaryFields;
	
	protected $cancelEditingConfirmationMessage;
	
	protected $canCollapseGroup;
	protected $canExpandMultipleRecords;
	protected $canExpandRecordProperty;
	protected $canExpandrecords;
	protected $expansionCanEdit;
	protected $maxExpandedRecords;
	protected $maxExpandedRecordsPrompt;	
	
	protected $canFreezeFields;
	protected $canGroupBy;
	protected $canPickFields;
	protected $canPickOmmittedFields;
	protected $canReorderFields;
	protected $canReorderRecords;
	protected $canResizeFields;
	protected $canSelectAll;
	protected $canSort;
	protected $canMultiSort;
	protected $canHover;
	
	protected $cellHeight;
	protected $cellPadding;
	
	protected $childExpansionMode;
	protected $expansionMode;
	protected $detailDS;
	protected $detailField;
	
	protected $clearAllSortingText;
	protected $clearFilterText;
	protected $clearSortFieldText;
	protected $configureSortText;
	
	protected $confirmCancelEditing;
	protected $confirmDiscardEdits;
	protected $confirmDiscardEditsMessage;
	protected $discardEditsSaveButtonTitle;
	
	protected $data;
	protected $dataFetchMode;
	protected $dataPageSize;
	protected $dataProperties;
	
	protected $dataSource;
	
	protected $dataFormatter;
	protected $dateInputFormat;
	protected $datetimeFormatter;
	protected $timeFormatter;
	
	protected $defaultFields;
	protected $fields;
	
	protected $editFailedBaseStyle;
	protected $editFailedCSSText;
	protected $editPendingBaseStyle;
	protected $editPendingCSSText;
	protected $frozenBaseStyle;
	protected $frozenHeaderBaseStyle;
	protected $frozenHeaderTitleStyle;
	
	protected $emptyCellValue;
	protected $emptyMessage;
	protected $emptyMessageStyle;
	
	protected $filterByCell;
	protected $filterEditorHeight;
	protected $filterOnKeypress;
	protected $fixedFieldWidths;
	protected $fixedRecordHeights; 
	
	protected $generateClickOnEnter;
	protected $generateClickOnSpace;
	protected $generateDoubleClickOnEnter;
	protected $generateDoubleClickOnSpace;
	
	protected $groupByField;
	protected $groupByMaxRecords;
	protected $groupNodeStyle;
	protected $groupStartOpen;
	protected $groupSummaryStyle;
	protected $groupTitleField;
	protected $nullGroupTitle;
	
	protected $headerBackgroundColor;
	protected $headerBarStyle;
	protected $headerBaseStyle;
	protected $headerHeight;
	protected $headerTitleStyle;
	
	protected $headerSpans;
	protected $headerSpanVAlign;
	protected $unspannedHeaderVAlign;
	
	protected $hoverMode;
	protected $hoverStyle;
	
	protected $imageSize;
	
	protected $initialCriteria;
	protected $initialSort;
	
	protected $leaveScrollbarGap;
	
	protected $loadingDataMessage;
	protected $loadingDataMessageStyle;
	protected $loadingMessage;
	
	protected $minFieldWidth;
	
	protected $modalEditing;
	
	protected $neverValidate;
	
	protected $normalBaseStyle;
	protected $normalCellHeight;
	
	protected $offlineMessageStyle;
	protected $recordSummaryBaseStyle;
	
	protected $rowNumberField;
	protected $rowNumberStart;
	protected $rowNumberStyle;
	
	protected $saveByCell;
	
	protected $selectionAppearance;
	protected $selectionProperty;
	protected $selectionType;
	
	protected $selectOnEdit;
	
	protected $showAllColumns;
	protected $showAllRecords;
	protected $showBackgroundComponent;
	protected $showCellContextMenus;
	protected $showDetailFields;
	protected $showEmptyMessage;
	protected $showFilterEditor;
	protected $showGridSummary;
	protected $showGroupSummary;
	protected $showHeader;
	protected $showHeaderContextMenu;
	protected $showHeaderMenuButton;
	protected $showHover;
	protected $showHoverComponents;
	protected $showRecordComponents;
	protected $showRecordComponentsByCell;
	protected $showRollOver;
	protected $showRollOverCanvas;
	protected $showRowNumbers;
	protected $showSelectedStyle;
	protected $showSelectionCanvas;
	protected $showSortArrow;
	protected $showTreeColumnPicker;
	protected $shrinkForFreeze;
	
	protected $sortDirection;
	protected $sortField;
	
	protected $stopOnErrors;
	
	protected $styleName;
	
	protected $summaryRowCriteria;
	protected $summaryRowDatSource;
	protected $sumamryRowHeight;
	protected $summaryRowStyle;
	
	protected $titleField;
	
	protected $useAllDataSourceFields;
	protected $useCellRollOvers;
	
	protected $validateByCell;
	protected $validateOnChange;
	
	protected $virtualScrolling;
	
	protected $waitForSave;
	
	protected $wrapCells;
	
	// Function
	protected $recordClick;
	protected $recordDoubleClick;
	
	/**
	 * Constructeur
	 * @param unknown_type $id
	 */
	public function ListGrid ($id) {
		parent::Canvas($id);
		
		$this->headerSpans = array();
		$this->fields = array();
		$this->defaultFields = array();
		$this->initialSort = array();
		$this->data = array();
	}
	
	/**
	 * Ajouter un champ
	 * @param ListGridField $field
	 */
	public function addField(ListGridField $field) {
		$this->fields[] = $field;
	}
	
	/**
	 * Defini le recordClick
	 * @param unknown_type $expression
	 */
	public function setJSRecordClick($expression) {
		$func = new FunctionType(array('viewer', 'record', 'recordNum', 'field', 'fieldNum', 'value', 'rawValue'), $expression);
		$this->recordClick = $func;
	}
	
	/**
	 * Defini le recordDoubleClick
	 * @param unknown_type $expression
	 */
	public function setJSRecordDoubleClick($expression) {
		$func = new FunctionType(array('viewer', 'record', 'recordNum', 'field', 'fieldNum', 'value', 'rawValue'), $expression);
		$this->recordDoubleClick = $func;
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}

	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}
	
	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "isc.".$this->object().".create({".$this->properties()."})";
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class ListGridField extends Bones implements IRenderable {
	
	protected $align;
	protected $cellAlign;
	
	protected $autoFetchDisplayMap;
	
	protected $autoFitWidth;
	protected $autoFitWidthApproach;
	
	protected $autoFreeze;
	
	protected $baseStyle;
	
	protected $canDragResize;
	protected $canEdit;
	protected $canExport;
	protected $canFilter;
	protected $canFreeze;
	protected $canGroupBy;
	protected $canHide;
	protected $canReorder;
	protected $canSort;
	protected $canSortClientOnly;
	protected $canToggle;
	
	protected $cellIcon;
	
	protected $defaultFilterValue;
	protected $defaultGroupingMode;
	protected $defaultIconSrc;
	protected $defaultValue;
	
	protected $optionDataSource;
	protected $optionCriteria;
	protected $optionTextMatchStyle;
	protected $displayField;
	protected $valueField;
	
	protected $displayFormat;
	protected $inputFormat;
	
	protected $editorProperties;
	protected $editorType;
	protected $editorValueMap;
	
	protected $emptyCellValue;
	
	protected $enterKeyEditAction;
	protected $escapeKeyEditAction;
	
	protected $filterEditorType;
	protected $filterEditorValueMap;
	
	protected $filterOnKeypress;
	
	protected $formatGridSummary;
	protected $formatGroupSummary;
	
	protected $frozen;
	
	protected $groupGranularity;
	
	protected $headerBaseStyle;
	protected $headerTitleStyle;
	
	protected $includeInRecordSummary;
	protected $includeInRecordSummaryFields;
	
	protected $isRemoveField;
	
	protected $linkText;
	protected $linkURLPrefix;
	protected $linkURLSuffix;
	protected $target;
	
	protected $name;
	protected $title;
	protected $type;
	protected $width;
	
	protected $partialSummary;
	
	protected $prompt;
	
	protected $recordSummaryFunction;
	protected $summaryFunction;
	
	protected $required;
	
	protected $showAlternateStyle;
	protected $showDefaultContextMenu;
	protected $showDisabledIcon;
	protected $showDownIcon;
	protected $showFileInline;
	protected $showGridSummary;
	protected $showGroupSummary;
	protected $showHover;
	protected $showRollOverIcon;
	protected $showSelectedIcon;
	protected $showValueIconOnly;
	
	protected $sortByDisplayField;
	protected $sortDirection;
	
	protected $summaryTitle;
	
	protected $suppressValueIcon;
	
	protected $validateOnChange;
	
	protected $validators;
	
	protected $valueIcons;
	
	protected $valueMap;
	
	/**
	 * Enter description here ...
	 * @param unknown_type $name
	 * @param unknown_type $title
	 * @param unknown_type $type
	 * @param unknown_type $witdh
	 */
	public function ListGridField($name, $title, $type, $witdh = null) {
		$this->name = $name;
		$this->title = $title;
		$this->type = $type;
		$this->width = $witdh;
		
		$this->includeInRecordSummaryFields = array();
		$this->valueMap = array();
		$this->validators = array();
		$this->editorValueMap = array();
	}
	
	/**
	 * Implementation de object
	 * @see IRenderable::object()
	 */
	public function object() {
		return get_class($this);
	}

	/**
	 * Implementation de properties
	 * @see IRenderable::properties()
	 */
	public function properties() {
		return parent::getProp($this);
	}

	/**
	 * Implementation de scLog
	 * @see IRenderable::scLog()
	 */
	public function scLog() {
		ScCollectionLog::getInstance()->addSc(new ScLog($this->object(), get_object_vars($this)));
	}
	
	/**
	 * Implementation de render
	 * @see IScreen::render()
	 */
	public function render() {
		$this->scLog();
		return "{".$this->properties()."}";
	}
}
